<template>
  <van-cell v-for="item in list" :key="item.id">
    <p style="display: flex; justify-content: space-between; align-items: center">
      <a style="text-align: left">车牌号：{{ item.chepai }}</a>
      <a style="text-align: right">时间：{{ item.shijian }}</a>
    </p>
    <van-button
      plain
      hairline
      type="primary"
      @click="selectchejianitemByid(item.id, item.chepai, item.shijian)"
      >查看报告</van-button
    >
    <van-button plain hairline type="success" @click="selectchejianjiluByid(item.id)"
      >查看证明</van-button
    >
  </van-cell>
</template>
<script setup>
import { ref } from 'vue'
import { Select, selectbaogao } from '@/api/xiaoxi'
import { useRouter } from 'vue-router'
const userrouter = useRouter()
const uid = JSON.parse(localStorage.getItem('user')).data.userId
const list = ref([])
console.log(uid)
Select(uid).then((res) => {
  list.value = res.data.result
  console.log(list.value)
})
function selectchejianitemByid(chejianjiluid, chepai, shijian) {
  console.log(chepai)
  console.log(shijian)
  selectbaogao(chejianjiluid).then((res) => {
    console.log(res.data.result)
    userrouter.push({
      path: '/pages/car/chejianbaogao',
      query: { data: JSON.stringify(res.data.result), chepai: chepai, shijian: shijian },
    })
  })
}
function selectchejianjiluByid(id) {
  console.log(id)
  userrouter.push({ path: '/pages/car/baogao', query: { data: JSON.stringify(id) } })
}
</script>
<style scoped></style>
